import 'package:guochaoapp/model/invoice_entity.dart';

invoiceEntityFromJson(InvoiceEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new InvoiceData().fromJson(json['data']);
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> invoiceEntityToJson(InvoiceEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] = entity.data.toJson();
	}
	data['sign'] = entity.sign;
	return data;
}

invoiceDataFromJson(InvoiceData data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['companyName'] != null) {
		data.companyName = json['companyName'].toString();
	}
	if (json['taxpayerIdNum'] != null) {
		data.taxpayerIdNum = json['taxpayerIdNum'].toString();
	}
	if (json['registerAddr'] != null) {
		data.registerAddr = json['registerAddr'].toString();
	}
	if (json['registerPhone'] != null) {
		data.registerPhone = json['registerPhone'].toString();
	}
	if (json['branchName'] != null) {
		data.branchName = json['branchName'].toString();
	}
	if (json['cardNo'] != null) {
		data.cardNo = json['cardNo'].toString();
	}
	if (json['receiverName'] != null) {
		data.receiverName = json['receiverName'].toString();
	}
	if (json['receiverPhone'] != null) {
		data.receiverPhone = json['receiverPhone'].toString();
	}
	if (json['receiverAddr'] != null) {
		data.receiverAddr = json['receiverAddr'].toString();
	}
	return data;
}

Map<String, dynamic> invoiceDataToJson(InvoiceData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['companyName'] = entity.companyName;
	data['taxpayerIdNum'] = entity.taxpayerIdNum;
	data['registerAddr'] = entity.registerAddr;
	data['registerPhone'] = entity.registerPhone;
	data['branchName'] = entity.branchName;
	data['cardNo'] = entity.cardNo;
	data['receiverName'] = entity.receiverName;
	data['receiverPhone'] = entity.receiverPhone;
	data['receiverAddr'] = entity.receiverAddr;
	return data;
}